function getOrder(orderId) {
	$.post(getHttpRequestPath("/order/getOrder"), {
		orderId : orderId
	}, function(typesString) {
		var order = JSON.parse(typesString, function(key, value) {
			return value;
		});
		initOrder(order);
	});
}

function saveOrder() {
	var cmd = new Cmd();
	var orderId = $("#orderId_text").val();
	cmd.orderId = orderId.length > 0 ? orderId : null;
	var sku = $("#sku_text").combobox('getValue');
	cmd.sku = sku.length > 0 ? sku : null;
	var amount = $("#amount_text").val();
	cmd.amount = amount.length > 0 ? new Number(amount) : 0;
	var zoneCode = $('#zone_text').combobox('getValue');
	cmd.zoneCode = zoneCode.length > 0 ? new Number(zoneCode) : 0;
	var address = $("#address_text").val();
	cmd.address = address.length > 0 ? address : null;
	var receiver = $("#receiver_text").val();
	cmd.receiver = receiver.length > 0 ? receiver : null;
	var phone = $("#phone_text").val();
	cmd.phone = phone.length > 0 ? phone : null;
	$.post(url, {
		jsonObj : JSON.stringify(cmd, cmd.StringifyReplacer)
	}, function(response) {
		if (response.toLowerCase() == "success") {
			$.messager.alert('系统提示', '保存成功!');
			$('#dg').datagrid('reload');
			$('#dlg').dialog('close');
		} else if (response.toLowerCase() == "exist") {
			$.messager.alert('系统提示', '该运单已存在!');
		} else if (response.toLowerCase() == "noexist") {
			$.messager.alert('系统提示', '该运单不存在!');
			$('#dg').datagrid('reload');
			$('#dlg').dialog('close');
		} else {
			$.messager.alert('系统提示', '保存出错!');
		}
	});
}

function verify(orderId) {
	$.messager.confirm('系统提示', '确定审核通过此运单吗?', function(r) {
		if (r) {
			$.post(getHttpRequestPath("/order/verify"), {
				orderId : orderId
			}, function(response) {
				if (response.toLowerCase() == "success") {
					$.messager.alert('系统提示', '审核成功!');
					$('#dg').datagrid('reload');
				} else {
					$.messager.alert('系统提示', '审核出错!');
				}
			}).error(_error);
		}
	});
}

function cancel(orderId) {
	$.messager.confirm('系统提示', '确定取消此运单吗?', function(r) {
		if (r) {
			$.post(getHttpRequestPath("/order/cancel"), {
				orderId : orderId
			}, function(response) {
				if (response.toLowerCase() == "success") {
					$.messager.alert('系统提示', '取消成功!');
					$('#dg').datagrid('reload');
				} else {
					$.messager.alert('系统提示', '取消出错!');
				}
			}).error(_error);
		}
	});
}

function confirm(orderId) {
	$.messager.confirm('系统提示', '确定签收此运单吗?', function(r) {
		if (r) {
			$.post(getHttpRequestPath("/order/confirm"), {
				orderId : orderId
			}, function(response) {
				if (response.toLowerCase() == "success") {
					$.messager.alert('系统提示', '签收成功!');
					$('#dg').datagrid('reload');
				} else {
					$.messager.alert('系统提示', '签收出错!');
				}
			}).error(_error);
		}
	});
}